import Vue from "vue";
import Router from "vue-router";
Vue.use(Router);

export default new Router({
	mode: "history", // history 模式去除地址栏 # 号
	routes: [
		// 一级路由，渲染到 App.vue 中的 <router-view />
		{
			// http://127.0.0.1:8080/#/login
			path: "/login",
			name: "登陆模块",
			component: () => import("@/components/account/Login.vue"),
		},
		// 二级路由
		{
			// http://127.0.0.1:8080/#/
			path: "/",
			name: "",
			component: () => import("@/components/Layout.vue"),
			// 重定向
			redirect: "/index",
			// 二级路由，渲染到该组件中的 <router-view />
			children: [
				{
					// http://127.0.0.1:8080/#/index
					path: "/index",
					name: "系统首页",
					// ES6 箭头函数写法
					component: () => import("@/components/common/Dashboard.vue"),
					meta: { requireAuth: true },
				},
			],
		},
		{
			// http://127.0.0.1:8080/#/
			path: "/account",
			name: "用户管理",
			component: () => import("@/components/Layout.vue"),
			// 重定向
			redirect: "/profile",
			// 二级路由，渲染到该组件中的 <router-view />
			children: [
				{
					// http://127.0.0.1:8080/#/account/profile
					path: "/account/profile",
					name: "个人主页",
					// ES6 箭头函数写法
					component: () => import("@/components/account/Profile.vue"),
				},
				{
					// http://127.0.0.1:8080/#/account/users
					path: "/account/users",
					name: "用户列表",
					// ES6 箭头函数写法
					component: () => import("@/components/account/Users.vue"),
				},
			],
		},
		{
			// http://127.0.0.1:8080/#/
			path: "/product",
			name: "商品管理",
			component: () => import("@/components/Layout.vue"),
			// 重定向
			redirect: "/Category",
			// 二级路由，渲染到该组件中的 <router-view />
			children: [
				{
					path: "/product/Category",
					name: "商品种类管理",
					// ES6 箭头函数写法
					component: () => import("@/components/product/Category.vue"),
				},
				{
					path: "/product/Products",
					name: "商品种类管理",
					// ES6 箭头函数写法
					component: () => import("@/components/product/Products.vue"),
				},
			],
		},
		{
			// http://127.0.0.1:8080/#/
			path: "/orders",
			name: "订单管理",
			component: () => import("@/components/Layout.vue"),
			// 二级路由，渲染到该组件中的 <router-view />
			children: [
				{
					path: "/orders/OrderItem",
					name: "订单管理",
					// ES6 箭头函数写法
					component: () => import("@/components/orders/OrderItem.vue"),
				},
			],
		},
	],
});